
var RecentCounter = function () {
    this.queue = []
};

/** 
 * @param {number} t
 * @return {number}
 */
RecentCounter.prototype.ping = function (t) {
    this.queue.push(t)
    const time = t - 3000
    while (this.queue[0] < time) {
        this.queue.shift()
    }
    return this.queue.length
};

/**
 * example
 */
var counter = new RecentCounter();
var result1 = counter.ping(1000);
console.log(result1);
var result2 = counter.ping(3001);
console.log(result2);
var result3 = counter.ping(8000);
console.log(result3);
/** 
 * Your RecentCounter object will be instantiated and called as such:
 * var obj = new RecentCounter()
 * var param_1 = obj.ping(t)
 */